import React, { Component, Fragment} from 'react'
import { Route, Routes } from 'react-router-dom'
import Main from '../Main'
import {connect} from 'react-redux'
import {createLoginAction} from '../../redux/actions/loginAction'
import PubSub from 'pubsub-js'
import Logininput from '../Logininput'
import DeviceLogin from '../DeviceLogin'

function LoginError(args) {
    const {msg} = {...args}

    return (
        <div style={{color:"red"}}>
            {msg}
        </div>
    )
}

class Mynative extends Component {
    
    
    componentDidMount() {
        // this.publish = PubSub.subscribe("login" , (msg , data)=>{
        //     this.setState({login:data.login_state , msg:data.msg})
        // })
    }
    // componentWillUnmount() {
    //     PubSub.unsubscribe(this.publish)
    // }
    
    render() {
        return (
            <Fragment>
                <Routes>
                    <Route path='/main/*' element={<Main/>}/>
                    <Route path='/' element={<DeviceLogin/>}/>
                    {/* <Route path='1' element={<div>1</div>}></Route> */}
                </Routes>
            </Fragment>
        )
    }
}
export default  
connect(
    state =>({login_state:state.login.login_state}) , 
    {
        useLogin:createLoginAction
    }
)(Mynative)